<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>居中练习</title>
    <style>
      .outer {
        width: 500px;
        height: 500px;
        background-color: aquamarine;
        overflow: hidden;
      }

      .inner {
        width: 250px;
        height: 250px;
        background-color: palegoldenrod;
        /* 方式一: 计算外边距,缺点: 必须直到内外元素的宽高并且设置完成后是固定的 */
        margin: 125px;

        /* 方式二: 定位*/

        /* 方式三: flex*/
      }

      .container {
        width: 200px;
        height: 200px;
        background-color: aquamarine;
        text-align: center;
      }

      span {
        line-height: 200px;
        background-color: palegoldenrod;
      }
    </style>
  </head>
  <body>
    <div class="outer">
      <div class="inner"></div>
    </div>

    <hr />

    <div class="container">
      <span>span</span>
    </div>
  </body>
</html>
